name: CLI prod release

on:
  release:
    types: [published]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup python
        uses: actions/setup-python@v2
        with:
          python-version: "3.8"
          architecture: "x64"

      - name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PWD }}

      - name: Docker Build
        run: docker build -f docker/Dockerfile -t zilliz/milvus_cli:${GITHUB_REF#refs/tags/} --build-arg VERSION=${GITHUB_REF#refs/tags/} .

      - name: Docker tag
        run: docker tag zilliz/milvus_cli:${GITHUB_REF#refs/tags/} zilliz/milvus_cli:latest

      - name: Docker Push lastest
        run: docker push zilliz/milvus_cli
